From 7052795a80dd393e8522717027ff0dc5d6c9ab94 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 15 May 2014 17:12:09 -0400 Subject: [PATCH] wayland: Clean up code to find the correct seat for a window --- gdk/wayland/gdkwindow-wayland.c | 48 +++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index 87fa392a05..aaab00aab8 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -990,6 +990,33 @@ gdk_wayland_window_create_xdg_popup (GdkWindow *window, xdg_popup_add_listener (impl->xdg_popup, &xdg_popup_listener, window); } +static struct wl_seat * +find_grab_input_seat (GdkWindow *window, GdkWindow *transient_for) +{ + struct wl_seat *grab_input_seat = NULL; + GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); + GdkWindowImplWayland *tmp_impl; + + /* Use the device that was used for the grab as the device for + * the popup window setup - so this relies on GTK+ taking the + * grab before showing the popup window. + */ + grab_input_seat = impl->grab_input_seat; + + tmp_impl = GDK_WINDOW_IMPL_WAYLAND (transient_for->impl); + while (!grab_input_seat) + { + grab_input_seat = tmp_impl->grab_input_seat; + + if (tmp_impl->transient_for) + tmp_impl = GDK_WINDOW_IMPL_WAYLAND (tmp_impl->transient_for->impl); + else + break; + } + + return grab_input_seat; +} + static void gdk_wayland_window_map (GdkWindow *window) { @@ -1018,26 +1045,7 @@ gdk_wayland_window_map (GdkWindow *window) if (transient_for) { - struct wl_seat *grab_input_seat = NULL; - GdkWindowImplWayland *tmp_impl; - - /* Use the device that was used for the grab as the device for - * the popup window setup - so this relies on GTK+ taking the - * grab before showing the popup window. - */ - grab_input_seat = impl->grab_input_seat; - - tmp_impl = GDK_WINDOW_IMPL_WAYLAND (transient_for->impl); - while (!grab_input_seat) - { - grab_input_seat = tmp_impl->grab_input_seat; - - if (tmp_impl->transient_for) - tmp_impl = GDK_WINDOW_IMPL_WAYLAND (tmp_impl->transient_for->impl); - else - break; - } - + struct wl_seat *grab_input_seat = find_grab_input_seat (window, transient_for); if (grab_input_seat && (impl->hint == GDK_WINDOW_TYPE_HINT_POPUP_MENU || impl->hint == GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU || -- 2.30.2